<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/jsp/taglib.jsp"%>
<%@page import="com.framework.utils.ConfigUtil"%>
<%@ page import="com.biz.conf.Global" %>
<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>jqGird</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="${ctxStatic}/plugins/h+/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/animate.min.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="${ctxStatic}/plugins/h+/css/plugins/webuploader/webuploader.css">
    <link href="${ctxStatic}/plugins/h+/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">

    <link href="${ctxStatic}/plugins/h+/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/colorpicker/css/bootstrap-colorpicker.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/cropper/cropper.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/switchery/switchery.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/jasny/jasny-bootstrap.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/nouslider/jquery.nouislider.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/ionRangeSlider/ion.rangeSlider.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/ionRangeSlider/ion.rangeSlider.skinFlat.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/clockpicker/clockpicker.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/animate.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/style.min.css?v=4.0.0" rel="stylesheet"><base target="_blank">
    <style>
        .ml10 {
            margin-left: 15px;
        }

    </style>

</head>

<body class="gray-bg" >
<div class="wrapper wrapper-content animated fadeInRight" id="ccbb">
    <div class="row">
        <div class="col-sm-12">
            <span id="spancc" class="spancc"></span>
            <div class="row">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>搜索条件</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content" >
                        <div class="row">
                            <div class="col-md-2"><input placeholder="登录名" id="q_login_name" style="width:200px;" class="form-control" ></div>
                            <div class="col-md-2"><input placeholder="姓名" id="q_person_name"  style="width:200px;" class="form-control" ></div>
                            <div class="col-md-1"><button id="btn_search" class="btn btn-primary"><i class="fa fa-search"></i>&nbsp;搜索</button></div>
                        </div>
                    </div>
                </div>
            </div>
            <table id="merchantTablePagin"></table>
        </div>
    </div>
    </div>
</body>
<script src="${ctxStatic}/plugins/h+/js/jquery.min.js?v=2.1.4"></script>
<script src="${ctxStatic}/plugins/h+/js/bootstrap.min.js?v=3.3.6"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/bootstrap-table.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/locale/bootstrap-table-zh-CN.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/extensions/export/bootstrap-table-export.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/extensions/editable/bootstrap-table-editable.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="${ctxStatic}/plugins/h+/js/content.min.js?v=1.0.0"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/chosen/chosen.jquery.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/layer/laydate/laydate.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/layer2.4/layer.js"></script>
    <script>

    </script>
    <script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
    <script type="text/javascript">
        var picPath='<%=ConfigUtil.get("OSSURL")%>';
        //初始化表格对象
        var $table = $('#merchantTablePagin');

        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引

        /*
         获取选中行的相关数据
         */
        $(function () {
            $table.on('click-row.bs.table', function (e, row, $element) {
                $('.success').removeClass('success');
                $($element).addClass('success');
            });

        });
        function getSelectedRow() {
            var index = $table.find('tr.success').data('index');
            return $table.bootstrapTable('getData')[index];
        }


        /*
         每一列详情格式化数据
         */
        function formDetail(index, row) {
            return row.customer+index;
        }

        function reloadTable() {
            $table.bootstrapTable('selectPage', 1);
            $table.bootstrapTable('refresh', queryParams);
        }


        ////////////////////////////////////////////////////////////////////////////////////////以下是通过js方式初始化BootStrapTable/////////////////////////////////////////////

        $table.bootstrapTable({
            url: "${pageContext.request.contextPath}/sysUser/showSysUserGrid2.ac",
            method: 'post',
            contentType: "application/x-www-form-urlencoded",//必须的
            dataType: "json",
            pageList:[10, 20, 50, 100],//会根据当前的数据量加载合适的pageList
            height: $(window).height() ,
            //cardView:true,//是否自适应手机
            pagination: true, //分页
            // queryParamsType: "limit",
            singleSelect: false,
            cache:false,
            sortName:"name",
            search: false, //显示搜索框
            showColumns:false,
            showRefresh:false,
            showToggle:false,
           //showPaginationSwitch:true,
            smartDisplay:false,
            detailView:false,
            toolbar:"#toolbar",
            queryParams: queryParams,//参数
            searchOnEnterKey:true,
            detailFormatter:function(index, row, element){
                return row.name;
            },
            sidePagination: "server", //服务端处理分页
            columns: [
                {
                    visible:false,
                    field:'id'
                },
                {
                    title: '登录名',
                    field: 'loginName',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                },
                {
                    title: '姓名',
                    field: 'personName',
                    sortStable:true,
                    align: 'center'
                },
                {
                    title: '用户类型',
                    field: 'identity',
                    formatter:function (value, row, index) {
                        if(row.identity==1)
                        {
                            return "管理员";
                        }else if(row.identity==2)
                        {
                            return "平台";
                        }else if(row.identity==3)
                        {
                            return "一级代理商";
                        }
                    }
                },
                {
                    title: '红利',
                    field: 'profit',
                    formatter:function (value, row, index) {
                        return value+"%";
                    }
                },
                {
                    title: '邮箱',
                    field: 'email',
                    align: 'center'
                },
                {
                    title: '手机',
                    field: 'phone',
                    align: 'center'
                },
                {
                    title: '操作',
                    align: 'center',
                    events:{
                        /* 'click .like': function (e, value, row, index) {
                         alert('You click like icon, row: ' + JSON.stringify(row));
                         },*/
                        'click .save': function (e, value, row, index) {
                            // alert('You click edit icon, row: ' + JSON.stringify(row));
                            //弹出编辑层
                            selectSysUser(row.id,row.loginName,row.personName);
                        }
                    },
                    formatter:function(value,row,index){
                        return [
                            '<a class="save ml10" href="javascript:void(0)" title="选择" >',
                            '<i class="glyphicon ">选择</i>',
                            '</a>'
                        ].join('');
                    }
                }
            ]
        });

        /*
         搜索按钮
         */
        $("#btn_search").click(function(){
            $table.bootstrapTable('selectPage', 1);
            $table.bootstrapTable('refresh', queryParams);
        });

        function selectSysUser(sysUserId,loginName,personName) {

            var d = window.parent.document.getElementById('layui-layer-iframe${index}').contentWindow;
            d.setSysUser(sysUserId,loginName,personName);
            parent.layer.close(index);
        }

        /*
         传递的参数
         */
        function queryParams(params) {
            var name=$("#search_customer").val();
            var speed_code=$("#search_group").val();
            var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                limit: params.limit,  //页面大小
                offset: params.offset, //页码
                pageindex:params.pageNumber,
                login_name: $("#q_login_name").val(),
                person_name: $("#q_person_name").val()
            };
            return temp;
        }
        ///////////////////////////////////////////////////////////////toolbar///////////////////////////////////////





        /*
         获取所有选中的CheckBox的主键值 【数组】
         */
        function getSelections() {
            return $.map($table.bootstrapTable('getSelections'), function (row) {
                return row.id;
            });
        }

        /*
         BootStrapTable CheckBox 状态初始化
         */
        function stateFormatter2(value, row, index) {
            if (row.id === 2) {
                return {
                    disabled: true,
                    checked: true
                };
            }
            if (row.id === 0) {
                return {
                    disabled: true,
                    checked: true
                }
            }
            return value;
        }

function saveGoods(goodsId,name) {
    window.parent.saveGood(goodsId,name);
    parent.layer.close(index);
}
        
        
        
    </script>



</html>
